﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLBH.Base;
using QLBH.DataModel;
using QLBH.ModelInterface;

namespace QLBH.FeatureModel
{
    public class Kho_MatHangModel:IKho_MatHangModel
    {
        public Guid KHOID { set; get; }
        public Guid MHID { set; get; }
        public int SOLUONG { set; get; }
        public decimal GIANHAP { set; get; }
        public decimal GIABANLE { set; get; }
        public decimal GIABANBUON { set; get; }
        public decimal CHIETKHAU { set; get; }
        public void InitFromEntity(KHO_MATHANG entity)
        {
            this.CHIETKHAU  = (decimal)entity.CHIETKHAU;
            this.GIABANBUON = (decimal)entity.GIABANBUON;
            this.GIABANLE   = (decimal)entity.GIABANLE;
            this.GIANHAP    = (decimal)entity.GIANHAP;
            this.KHOID      = entity.KHOID;
            this.MHID       = entity.MHID;
            this.SOLUONG    = entity.SOLUONG;
        }

        public KHO_MATHANG ToEntity()
        {
            KHO_MATHANG entity  = new KHO_MATHANG();
            entity.CHIETKHAU    =this.CHIETKHAU ;
            entity.GIABANBUON   =this.GIABANBUON;
            entity.GIABANLE     =this.GIABANLE;
            entity.GIANHAP      =this.GIANHAP ;
            entity.KHOID        =this.KHOID;
            entity.MHID         =this.MHID;
            entity.SOLUONG      = this.SOLUONG;

            return entity;
        }
        public void InitFromNKMatHangModel(INKMatHangModel nkmathangModel)
        {
            this.CHIETKHAU = nkmathangModel.CHIETKHAU;
            this.GIABANBUON = nkmathangModel.DONGIA * (decimal)1.1;// default is 110% of DONGIA
            this.GIABANLE = nkmathangModel.DONGIA * (decimal)1.2;// default is 120% of DONGIA
            this.GIANHAP = nkmathangModel.DONGIA;
            this.MHID = nkmathangModel.MHID;
            this.SOLUONG = nkmathangModel.SOLUONG;            
        }
    }
}
